//
//  NSString+replaceCaseInsensitive.m
//  Bus
//
//  Created by wangjiajia on 13-12-5.
//  Copyright (c) 2013年 wangjiajia. All rights reserved.
//

#import "NSString+replace.h"

@implementation NSString (replace)
-(NSString*) replaceCaseInsensitive:(NSString*)oldStr :(NSString*)newStr{
    //1、直接
    return  [self stringByReplacingOccurrencesOfString:oldStr withString:newStr options:NSCaseInsensitiveSearch range:NSMakeRange(0, self.length)];
    
    //2、带return的define
#define returnReplaceCaseInsenstive(str,oldStr,newStr)  return [str stringByReplacingOccurrencesOfString:oldStr withString:newStr options:NSCaseInsensitiveSearch range:NSMakeRange(0, str.length)];
    
    //returnReplaceCaseInsenstive(self,oldStr,newStr);//define中有return
    
    //3、不带return的define
#define replaceCaseInsenstive(str,oldStr,newStr)  [str stringByReplacingOccurrencesOfString:oldStr withString:newStr options:NSCaseInsensitiveSearch range:NSMakeRange(0, str.length)];
    //return   replaceCaseInsenstive(self, oldStr, newStr);//define中没有return

}

-(NSString*) replaceRegex:(NSString*)regexStr :(NSString*)newStr{
    return [self stringByReplacingOccurrencesOfString:regexStr withString:newStr options:NSRegularExpressionSearch|NSCaseInsensitiveSearch range:NSMakeRange(0, self.length)];
}
@end
